<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = [1, 2, 3]
      // 这种将函数作为参数传递给其他函数，或者将函数作为返回值的函数被称为高阶函数
      Array.prototype.myForEach = function (callback) {
        for (let i = 0; i < this.length; i++) {
          callback(this[i], i)
        }
      }
      arr.myForEach((item, index) => {
        console.log(item)
        // console.log(index)
      })
    </script>
  </body>
</html>
